/*
 * TomasuloView.java
 */

package tomasulo;

import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import javax.swing.table.DefaultTableModel;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.awt.*;


/**
 * The application's main frame.
 */
public class TomasuloView extends FrameView {

    public TomasuloView(SingleFrameApplication app) {
        super(app);

        initComponents();
        this.getFrame().setResizable(false);

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
               // statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        //statusAnimationLabel.setIcon(idleIcon);
        //progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                     //   statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                  //  progressBar.setVisible(true);
                  //  progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                 //   statusAnimationLabel.setIcon(idleIcon);
                   // progressBar.setVisible(false);
                  //  progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                   // statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                  //  progressBar.setVisible(true);
                  //  progressBar.setIndeterminate(false);
                  //  progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = TomasuloApp.getApplication().getMainFrame();
            aboutBox = new TomasuloAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        TomasuloApp.getApplication().show(aboutBox);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        pcDevPanel = new javax.swing.JPanel();
        struQueLabel = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableStruQue = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        runningStateTable = new javax.swing.JTable();
        addStruButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        struTextField = new javax.swing.JTextArea();
        LoadFileButton = new javax.swing.JButton();
        SampleButton = new javax.swing.JButton();
        controlPanel = new javax.swing.JPanel();
        startButton = new javax.swing.JButton();
        pauseButton = new javax.swing.JButton();
        stopButton = new javax.swing.JButton();
        stepButton = new javax.swing.JButton();
        MemPanel = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        loadQueueTable = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        storeQueueTable = new javax.swing.JTable();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        memoryTable = new javax.swing.JTable();
        setMemButton = new javax.swing.JButton();
        getMemButton = new javax.swing.JButton();
        label1 = new javax.swing.JLabel();
        label2 = new javax.swing.JLabel();
        label3 = new javax.swing.JLabel();
        reservationPanel = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane8 = new javax.swing.JScrollPane();
        reservationStationTable = new javax.swing.JTable();
        label4 = new javax.swing.JLabel();
        label5 = new javax.swing.JLabel();
        label6 = new javax.swing.JLabel();
        label7 = new javax.swing.JLabel();
        label8 = new javax.swing.JLabel();
        timePanel = new javax.swing.JPanel();
        timeImageLabel = new javax.swing.JLabel();
        timeTextField = new javax.swing.JTextField();
        RegisterLabel = new javax.swing.JPanel();
        registerTitleLabel = new javax.swing.JLabel();
        jScrollPane9 = new javax.swing.JScrollPane();
        registerTable = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        delayTextField = new javax.swing.JTextField();
        setDelayButton = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

        mainPanel.setName("mainPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(tomasulo.TomasuloApp.class).getContext().getResourceMap(TomasuloView.class);
        pcDevPanel.setBackground(resourceMap.getColor("pcDevPanel.background")); // NOI18N
        pcDevPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pcDevPanel.setForeground(resourceMap.getColor("pcDevPanel.foreground")); // NOI18N
        pcDevPanel.setName("pcDevPanel"); // NOI18N

        struQueLabel.setFont(resourceMap.getFont("struQueLabel.font")); // NOI18N
        struQueLabel.setText(resourceMap.getString("struQueLabel.text")); // NOI18N
        struQueLabel.setName("struQueLabel"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tableStruQue.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "No", "Name", "Op1", "Op2", "Dst"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tableStruQue.setName("tableStruQue"); // NOI18N
        tableStruQue.setRowHeight(20);
        tableStruQue.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tableStruQue);
        tableStruQue.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("tableStruQue.columnModel.title4")); // NOI18N
        tableStruQue.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("tableStruQue.columnModel.title0")); // NOI18N
        tableStruQue.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("tableStruQue.columnModel.title1")); // NOI18N
        tableStruQue.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("tableStruQue.columnModel.title2")); // NOI18N
        tableStruQue.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("tableStruQue.columnModel.title3")); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        runningStateTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "No", "State", "Executed", "WriteBack"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Object.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        runningStateTable.setName("runningStateTable"); // NOI18N
        runningStateTable.setRowHeight(20);
        runningStateTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(runningStateTable);
        runningStateTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("runningStateTable.columnModel.title0")); // NOI18N
        runningStateTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("runningStateTable.columnModel.title3")); // NOI18N
        runningStateTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("runningStateTable.columnModel.title1")); // NOI18N
        runningStateTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("runningStateTable.columnModel.title2")); // NOI18N

        addStruButton.setText(resourceMap.getString("addStruButton.text")); // NOI18N
        addStruButton.setName("addStruButton"); // NOI18N
        addStruButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                addStruButtonMouseClicked(evt);
            }
        });

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        struTextField.setColumns(20);
        struTextField.setRows(5);
        struTextField.setName("struTextField"); // NOI18N
        jScrollPane3.setViewportView(struTextField);

        LoadFileButton.setText(resourceMap.getString("LoadFileButton.text")); // NOI18N
        LoadFileButton.setName("LoadFileButton"); // NOI18N
        LoadFileButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoadFileButtonActionPerformed(evt);
            }
        });

        SampleButton.setText(resourceMap.getString("SampleButton.text")); // NOI18N
        SampleButton.setName("SampleButton"); // NOI18N
        SampleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SampleButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pcDevPanelLayout = new javax.swing.GroupLayout(pcDevPanel);
        pcDevPanel.setLayout(pcDevPanelLayout);
        pcDevPanelLayout.setHorizontalGroup(
            pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pcDevPanelLayout.createSequentialGroup()
                .addGap(67, 67, 67)
                .addComponent(struQueLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 124, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addGap(91, 91, 91))
            .addGroup(pcDevPanelLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pcDevPanelLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(addStruButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(LoadFileButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(SampleButton, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        pcDevPanelLayout.setVerticalGroup(
            pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pcDevPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(struQueLabel)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pcDevPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pcDevPanelLayout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(SampleButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(LoadFileButton))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
                    .addComponent(addStruButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        controlPanel.setName("controlPanel"); // NOI18N

        startButton.setIcon(resourceMap.getIcon("startButton.icon")); // NOI18N
        startButton.setText(resourceMap.getString("startButton.text")); // NOI18N
        startButton.setName("startButton"); // NOI18N
        startButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                startButtonMouseClicked(evt);
            }
        });

        pauseButton.setIcon(resourceMap.getIcon("pauseButton.icon")); // NOI18N
        pauseButton.setText(resourceMap.getString("pauseButton.text")); // NOI18N
        pauseButton.setName("pauseButton"); // NOI18N
        pauseButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pauseButtonMouseClicked(evt);
            }
        });

        stopButton.setIcon(resourceMap.getIcon("stopButton.icon")); // NOI18N
        stopButton.setText(resourceMap.getString("stopButton.text")); // NOI18N
        stopButton.setName("stopButton"); // NOI18N
        stopButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                stopButtonMouseClicked(evt);
            }
        });

        stepButton.setIcon(resourceMap.getIcon("stepButton.icon")); // NOI18N
        stepButton.setText(resourceMap.getString("stepButton.text")); // NOI18N
        stepButton.setName("stepButton"); // NOI18N
        stepButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                stepButtonMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout controlPanelLayout = new javax.swing.GroupLayout(controlPanel);
        controlPanel.setLayout(controlPanelLayout);
        controlPanelLayout.setHorizontalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(startButton, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pauseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(stopButton, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(stepButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );
        controlPanelLayout.setVerticalGroup(
            controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(controlPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(controlPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(pauseButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(stopButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(stepButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(startButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(12, Short.MAX_VALUE))
        );

        MemPanel.setBackground(resourceMap.getColor("MemPanel.background")); // NOI18N
        MemPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        MemPanel.setName("MemPanel"); // NOI18N

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jScrollPane5.setName("jScrollPane5"); // NOI18N

        loadQueueTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Busy", "Address"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        loadQueueTable.setName("loadQueueTable"); // NOI18N
        loadQueueTable.setRowHeight(20);
        loadQueueTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane5.setViewportView(loadQueueTable);
        loadQueueTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("loadQueueTable.columnModel.title1")); // NOI18N
        loadQueueTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("loadQueueTable.columnModel.title2")); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jScrollPane6.setName("jScrollPane6"); // NOI18N

        storeQueueTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "State", "Address", "Value", "StationNo"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        storeQueueTable.setName("storeQueueTable"); // NOI18N
        storeQueueTable.setRowHeight(20);
        storeQueueTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane6.setViewportView(storeQueueTable);
        storeQueueTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("storeQueueTable.columnModel.title1")); // NOI18N
        storeQueueTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("storeQueueTable.columnModel.title2")); // NOI18N
        storeQueueTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("storeQueueTable.columnModel.title3")); // NOI18N
        storeQueueTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("storeQueueTable.columnModel.title4")); // NOI18N

        jLabel5.setFont(resourceMap.getFont("jLabel5.font")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jScrollPane7.setName("jScrollPane7"); // NOI18N

        memoryTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Address", "Data"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        memoryTable.setName("memoryTable"); // NOI18N
        memoryTable.setRowHeight(20);
        memoryTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane7.setViewportView(memoryTable);
        memoryTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("memoryTable.columnModel.title0")); // NOI18N
        memoryTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("memoryTable.columnModel.title1")); // NOI18N

        setMemButton.setText(resourceMap.getString("setMemButton.text")); // NOI18N
        setMemButton.setName("setMemButton"); // NOI18N
        setMemButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                setMemButtonActionPerformed(evt);
            }
        });

        getMemButton.setText(resourceMap.getString("getMemButton.text")); // NOI18N
        getMemButton.setName("getMemButton"); // NOI18N
        getMemButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                getMemButtonActionPerformed(evt);
            }
        });

        label1.setFont(resourceMap.getFont("label1.font")); // NOI18N
        label1.setForeground(resourceMap.getColor("label1.foreground")); // NOI18N
        label1.setText(resourceMap.getString("label1.text")); // NOI18N
        label1.setName("label1"); // NOI18N

        label2.setFont(resourceMap.getFont("label2.font")); // NOI18N
        label2.setForeground(resourceMap.getColor("label2.foreground")); // NOI18N
        label2.setText(resourceMap.getString("label2.text")); // NOI18N
        label2.setName("label2"); // NOI18N

        label3.setFont(resourceMap.getFont("label3.font")); // NOI18N
        label3.setForeground(resourceMap.getColor("label3.foreground")); // NOI18N
        label3.setText(resourceMap.getString("label3.text")); // NOI18N
        label3.setName("label3"); // NOI18N

        javax.swing.GroupLayout MemPanelLayout = new javax.swing.GroupLayout(MemPanel);
        MemPanel.setLayout(MemPanelLayout);
        MemPanelLayout.setHorizontalGroup(
            MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MemPanelLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(MemPanelLayout.createSequentialGroup()
                            .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(label2)
                                .addComponent(label3)
                                .addComponent(label1))
                            .addGap(19, 19, 19)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(MemPanelLayout.createSequentialGroup()
                            .addGap(126, 126, 126)
                            .addComponent(jLabel4))
                        .addGroup(MemPanelLayout.createSequentialGroup()
                            .addGap(126, 126, 126)
                            .addComponent(jLabel3)))
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(MemPanelLayout.createSequentialGroup()
                        .addGap(96, 96, 96)
                        .addComponent(jLabel5))
                    .addGroup(MemPanelLayout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(getMemButton)
                        .addGap(43, 43, 43)
                        .addComponent(setMemButton))
                    .addGroup(MemPanelLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(30, 30, 30))
        );
        MemPanelLayout.setVerticalGroup(
            MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MemPanelLayout.createSequentialGroup()
                .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(MemPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, MemPanelLayout.createSequentialGroup()
                                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel4)
                                .addGap(10, 10, 10)
                                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, MemPanelLayout.createSequentialGroup()
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(MemPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(setMemButton)
                                    .addComponent(getMemButton)))))
                    .addGroup(MemPanelLayout.createSequentialGroup()
                        .addGap(74, 74, 74)
                        .addComponent(label1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label3)))
                .addContainerGap(32, Short.MAX_VALUE))
        );

        reservationPanel.setBackground(resourceMap.getColor("reservationPanel.background")); // NOI18N
        reservationPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        reservationPanel.setName("reservationPanel"); // NOI18N

        jLabel6.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jScrollPane8.setName("jScrollPane8"); // NOI18N

        reservationStationTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, "MUL1", null, null, null, null, null, null},
                {null, "MUL2", null, null, null, null, null, null},
                {null, "ADD1", null, null, null, null, null, null},
                {null, "ADD2", null, null, null, null, null, null},
                {null, "ADD3", null, null, null, null, null, null}
            },
            new String [] {
                "Time", "Name", "Busy", "Op", "Vi", "Vk", "Qi", "Qk"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        reservationStationTable.setName("reservationStationTable"); // NOI18N
        reservationStationTable.setRowHeight(20);
        reservationStationTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane8.setViewportView(reservationStationTable);
        reservationStationTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title0")); // NOI18N
        reservationStationTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title1")); // NOI18N
        reservationStationTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title2")); // NOI18N
        reservationStationTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title3")); // NOI18N
        reservationStationTable.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title4")); // NOI18N
        reservationStationTable.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title5")); // NOI18N
        reservationStationTable.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title6")); // NOI18N
        reservationStationTable.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("reservationStationTable.columnModel.title7")); // NOI18N

        label4.setFont(resourceMap.getFont("label4.font")); // NOI18N
        label4.setForeground(resourceMap.getColor("label4.foreground")); // NOI18N
        label4.setText(resourceMap.getString("label4.text")); // NOI18N
        label4.setName("label4"); // NOI18N

        label5.setFont(resourceMap.getFont("label5.font")); // NOI18N
        label5.setForeground(resourceMap.getColor("label5.foreground")); // NOI18N
        label5.setText(resourceMap.getString("label5.text")); // NOI18N
        label5.setName("label5"); // NOI18N

        label6.setFont(resourceMap.getFont("label6.font")); // NOI18N
        label6.setForeground(resourceMap.getColor("label6.foreground")); // NOI18N
        label6.setText(resourceMap.getString("label6.text")); // NOI18N
        label6.setName("label6"); // NOI18N

        label7.setFont(resourceMap.getFont("label7.font")); // NOI18N
        label7.setForeground(resourceMap.getColor("label7.foreground")); // NOI18N
        label7.setText(resourceMap.getString("label7.text")); // NOI18N
        label7.setName("label7"); // NOI18N

        label8.setFont(resourceMap.getFont("label8.font")); // NOI18N
        label8.setForeground(resourceMap.getColor("label8.foreground")); // NOI18N
        label8.setText(resourceMap.getString("label8.text")); // NOI18N
        label8.setName("label8"); // NOI18N

        javax.swing.GroupLayout reservationPanelLayout = new javax.swing.GroupLayout(reservationPanel);
        reservationPanel.setLayout(reservationPanelLayout);
        reservationPanelLayout.setHorizontalGroup(
            reservationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(reservationPanelLayout.createSequentialGroup()
                .addGroup(reservationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(reservationPanelLayout.createSequentialGroup()
                        .addGap(156, 156, 156)
                        .addComponent(jLabel6))
                    .addGroup(reservationPanelLayout.createSequentialGroup()
                        .addContainerGap(18, Short.MAX_VALUE)
                        .addGroup(reservationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(label5)
                            .addComponent(label4)
                            .addComponent(label6)
                            .addComponent(label7)
                            .addComponent(label8))
                        .addGap(10, 10, 10)
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        reservationPanelLayout.setVerticalGroup(
            reservationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(reservationPanelLayout.createSequentialGroup()
                .addGroup(reservationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(reservationPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(reservationPanelLayout.createSequentialGroup()
                        .addGap(73, 73, 73)
                        .addComponent(label4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(label8)))
                .addContainerGap(22, Short.MAX_VALUE))
        );

        timePanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        timePanel.setName("timePanel"); // NOI18N

        timeImageLabel.setIcon(resourceMap.getIcon("timeImageLabel.icon")); // NOI18N
        timeImageLabel.setText(resourceMap.getString("timeImageLabel.text")); // NOI18N
        timeImageLabel.setName("timeImageLabel"); // NOI18N

        timeTextField.setBackground(resourceMap.getColor("timeTextField.background")); // NOI18N
        timeTextField.setEditable(false);
        timeTextField.setFont(resourceMap.getFont("timeTextField.font")); // NOI18N
        timeTextField.setForeground(resourceMap.getColor("timeTextField.foreground")); // NOI18N
        timeTextField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        timeTextField.setText(resourceMap.getString("timeTextField.text")); // NOI18N
        timeTextField.setName("timeTextField"); // NOI18N

        javax.swing.GroupLayout timePanelLayout = new javax.swing.GroupLayout(timePanel);
        timePanel.setLayout(timePanelLayout);
        timePanelLayout.setHorizontalGroup(
            timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(timePanelLayout.createSequentialGroup()
                .addComponent(timeImageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(timeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
                .addContainerGap())
        );
        timePanelLayout.setVerticalGroup(
            timePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(timeImageLabel, javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, timePanelLayout.createSequentialGroup()
                .addComponent(timeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10))
        );

        RegisterLabel.setBackground(resourceMap.getColor("RegisterLabel.background")); // NOI18N
        RegisterLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        RegisterLabel.setName("RegisterLabel"); // NOI18N

        registerTitleLabel.setFont(resourceMap.getFont("registerTitleLabel.font")); // NOI18N
        registerTitleLabel.setText(resourceMap.getString("registerTitleLabel.text")); // NOI18N
        registerTitleLabel.setName("registerTitleLabel"); // NOI18N

        jScrollPane9.setName("jScrollPane9"); // NOI18N

        registerTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Busy", null, null, null, null, null, null, null, null},
                {"StationNo", null, null, null, null, null, null, null, null},
                {"Value", null, null, null, null, null, null, null, null}
            },
            new String [] {
                "", "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        registerTable.setName("registerTable"); // NOI18N
        registerTable.setRowHeight(20);
        registerTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane9.setViewportView(registerTable);
        registerTable.getColumnModel().getColumn(0).setResizable(false);
        registerTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("registerTable.columnModel.title8")); // NOI18N
        registerTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("registerTable.columnModel.title0")); // NOI18N
        registerTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("registerTable.columnModel.title1")); // NOI18N
        registerTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("registerTable.columnModel.title2")); // NOI18N
        registerTable.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("registerTable.columnModel.title3")); // NOI18N
        registerTable.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("registerTable.columnModel.title4")); // NOI18N
        registerTable.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("registerTable.columnModel.title5")); // NOI18N
        registerTable.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("registerTable.columnModel.title6")); // NOI18N
        registerTable.getColumnModel().getColumn(8).setHeaderValue(resourceMap.getString("registerTable.columnModel.title7")); // NOI18N

        javax.swing.GroupLayout RegisterLabelLayout = new javax.swing.GroupLayout(RegisterLabel);
        RegisterLabel.setLayout(RegisterLabelLayout);
        RegisterLabelLayout.setHorizontalGroup(
            RegisterLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(RegisterLabelLayout.createSequentialGroup()
                .addGroup(RegisterLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(RegisterLabelLayout.createSequentialGroup()
                        .addGap(245, 245, 245)
                        .addComponent(registerTitleLabel))
                    .addGroup(RegisterLabelLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 551, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(2, Short.MAX_VALUE))
        );
        RegisterLabelLayout.setVerticalGroup(
            RegisterLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(RegisterLabelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(registerTitleLabel)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(51, Short.MAX_VALUE))
        );

        jLabel1.setName("jLabel1"); // NOI18N

        delayTextField.setFont(resourceMap.getFont("delayTextField.font")); // NOI18N
        delayTextField.setText(resourceMap.getString("delayTextField.text")); // NOI18N
        delayTextField.setName("delayTextField"); // NOI18N

        setDelayButton.setFont(resourceMap.getFont("setDelayButton.font")); // NOI18N
        setDelayButton.setForeground(resourceMap.getColor("setDelayButton.foreground")); // NOI18N
        setDelayButton.setText(resourceMap.getString("setDelayButton.text")); // NOI18N
        setDelayButton.setName("setDelayButton"); // NOI18N
        setDelayButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                setDelayButtonActionPerformed(evt);
            }
        });

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(reservationPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(RegisterLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 577, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addGap(125, 125, 125)
                                .addComponent(controlPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(pcDevPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(timePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(41, 41, 41)
                                .addComponent(setDelayButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(mainPanelLayout.createSequentialGroup()
                                        .addComponent(delayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel7))
                                    .addComponent(jLabel1))
                                .addGap(195, 195, 195))
                            .addComponent(MemPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 578, Short.MAX_VALUE))))
                .addGap(30, 30, 30))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(timePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(setDelayButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(delayTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, Short.MAX_VALUE)
                                        .addComponent(jLabel7))
                                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING))))
                        .addGap(13, 13, 13))
                    .addComponent(controlPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(MemPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pcDevPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(reservationPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(RegisterLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(13, 13, 13))
        );

        menuBar.setName("menuBar"); // NOI18N

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(tomasulo.TomasuloApp.class).getContext().getActionMap(TomasuloView.class, this);
        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setComponent(mainPanel);
        setMenuBar(menuBar);
    }// </editor-fold>//GEN-END:initComponents

  //  private Kernel kernel;
    private void startButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_startButtonMouseClicked
        // TODO add your handling code here:
        System.out.println("start button clicked!");
        TomasuloApp.kernel.kstart();
        uupdate(Kernel.kernel);
    }//GEN-LAST:event_startButtonMouseClicked

    private void pauseButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pauseButtonMouseClicked
        // TODO add your handling code here:
        System.out.println("pause button clicked!");
        TomasuloApp.kernel.kpause();
        uupdate(Kernel.kernel);
    }//GEN-LAST:event_pauseButtonMouseClicked

    private void stopButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_stopButtonMouseClicked
        // TODO add your handling code here:
        System.out.println("stop button clicked!");
        TomasuloApp.kernel.kstop();
        uupdate(Kernel.kernel);
    }//GEN-LAST:event_stopButtonMouseClicked

    private void stepButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_stepButtonMouseClicked
        // TODO add your handling code here:
        System.out.println("step button clicked!");
        TomasuloApp.kernel.kstep();
        uupdate(Kernel.kernel);
    }//GEN-LAST:event_stepButtonMouseClicked

    private void addStruButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_addStruButtonMouseClicked
        // TODO add your handling code here:
        System.out.println("add button clicked!");
        String s = struTextField.getText();//得到输入的命令，进行解析
        /**
         * 解析命令
         * TODO
         */
        String temp[] = s.split("\n");
        for(int i=0;i<temp.length;i++)
	{
		   System.out.println(temp[i]+"***");
                   TomasuloApp.kernel.manager.addInstruction(temp[i]);
        }
        if(temp.length > 0){
            Kernel.kernel.manager.finished=false;
        }
        uupdate(Kernel.kernel);
    }//GEN-LAST:event_addStruButtonMouseClicked


    private void setDelayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setDelayButtonActionPerformed
        // TODO add your handling code here:
        String s = delayTextField.getText();
        System.out.println("Delay:"+Integer.parseInt(s));
        TomasuloApp.kernel.setDelay( Integer.parseInt(s));
    }//GEN-LAST:event_setDelayButtonActionPerformed

    private void setMemButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_setMemButtonActionPerformed
        // add your handling code here:
        
        for (int i=0;i<memoryTable.getRowCount();i++){
            String mem = (String)memoryTable.getValueAt(i, 0);
            if(mem!=null){
                int addr = Integer.parseInt(mem);
                  String data = (String)memoryTable.getValueAt(i, 1);          
            if (addr>=0 && addr<=Memory.MAX_ADDR && data != null){
                TomasuloApp.kernel.memory.val[addr] = Double.valueOf(data);
            }
            }


        }
    }//GEN-LAST:event_setMemButtonActionPerformed

    
    private void getMem(){
        for (int i=0;i<memoryTable.getRowCount();i++){
           String mem = (String)memoryTable.getValueAt(i, 0);
           if(mem!=null){
                int add = Integer.parseInt(mem);
           /**
            * 得到对应地址的数据，TODO
            */
                if(add<=Memory.MAX_ADDR&&add >=0 ){
                    double data = TomasuloApp.kernel.memory.val[add];

                   String s = String.valueOf(data);
                   memoryTable.setValueAt(mem, i, 0);
                   memoryTable.setValueAt(s, i, 1);
                   /*String temp[] = {mem,s};
          
                     DefaultTableModel tableModel = (DefaultTableModel) tableStruQue .getModel();
                     tableModel.setRowCount(0);
                     tableModel.addRow(temp);*/
                }
            }
         }
    }
    
    private void getMemButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getMemButtonActionPerformed
        // TODO add your handling code here:
        getMem();
    }//GEN-LAST:event_getMemButtonActionPerformed

    private void SampleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SampleButtonActionPerformed
          DefaultTableModel tableModel = (DefaultTableModel) tableStruQue .getModel();
        tableModel.setRowCount(6);
        try
        {

                    //设置缺省指令
                    /**
                     * LD F6 34 R2
                     * LD F2 45 R3
                     * MUTID F0 F2 F4
                     * SUBD F8 F6 F2
                     * DIVD F10 F0 F6
                     * ADDD F6 F8 F2
                     */
					 Kernel.kernel.setMem(3,5);
					 Kernel.kernel.setMem(4,10);
                    String arr[][] = {{"0","LD","F6","3",""}
                    ,{"1","LD","F2","4",""}
                    ,{"2","ADDD","F6","F2","F4"}
                    ,{"3","SUBD","F4","F6","F2"}
                    ,{"4","DIVD","F2","F4","F6"}
                    ,{"5","MULD","F6","F6","F2"}};
                    //String str[] = {"Name","Desti","Source1","Source2"};
                    for (int i=0;i<arr.length;i++){
                        for(int j=0;j<arr[i].length;j++)
                        //tableModel.addRow(arr[i]);
                        tableStruQue.setValueAt(arr[i][j], i, j);
                    }
                    
                    //加入指令队列
                    for (int i=0;i<6;i++)
                    {
                        String cmd = arr[i][1];
                        for (int j=2;j<5;j++){
                            if (arr[i][j] != null){
                                cmd = cmd + " "+arr[i][j]; 
                            }
                        }
                        System.out.println(cmd);
                        TomasuloApp.kernel.manager.addInstruction(cmd);
                    }

        }catch(Exception e)
        {

        }

    }//GEN-LAST:event_SampleButtonActionPerformed

    private void LoadFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoadFileButtonActionPerformed
        Kernel.kernel.kstop();
        JFileChooser fc = new JFileChooser();
        int selected=fc.showOpenDialog(this.getFrame().getContentPane());
        File myFile = null;
        if (selected==JFileChooser.APPROVE_OPTION){

            myFile=fc.getSelectedFile();
            TomasuloApp.kernel.loadFile(myFile.getAbsolutePath());
            uupdate(Kernel.kernel);
            System.out.println("You have selected file: "+myFile.getName());
        }
    }//GEN-LAST:event_LoadFileButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton LoadFileButton;
    private javax.swing.JPanel MemPanel;
    private javax.swing.JPanel RegisterLabel;
    private javax.swing.JButton SampleButton;
    private javax.swing.JButton addStruButton;
    private javax.swing.JPanel controlPanel;
    private javax.swing.JTextField delayTextField;
    private javax.swing.JButton getMemButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JLabel label1;
    private javax.swing.JLabel label2;
    private javax.swing.JLabel label3;
    private javax.swing.JLabel label4;
    private javax.swing.JLabel label5;
    private javax.swing.JLabel label6;
    private javax.swing.JLabel label7;
    private javax.swing.JLabel label8;
    private javax.swing.JTable loadQueueTable;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JTable memoryTable;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JButton pauseButton;
    private javax.swing.JPanel pcDevPanel;
    private javax.swing.JTable registerTable;
    private javax.swing.JLabel registerTitleLabel;
    private javax.swing.JPanel reservationPanel;
    private javax.swing.JTable reservationStationTable;
    private javax.swing.JTable runningStateTable;
    private javax.swing.JButton setDelayButton;
    private javax.swing.JButton setMemButton;
    private javax.swing.JButton startButton;
    private javax.swing.JButton stepButton;
    private javax.swing.JButton stopButton;
    private javax.swing.JTable storeQueueTable;
    private javax.swing.JLabel struQueLabel;
    private javax.swing.JTextArea struTextField;
    private javax.swing.JTable tableStruQue;
    private javax.swing.JLabel timeImageLabel;
    private javax.swing.JPanel timePanel;
    private javax.swing.JTextField timeTextField;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
   
    public void uupdate(Kernel kernel){
        System.out.println("[UI.uupdate]");


        //更新tableStruQue
        String instrs[][] = kernel.manager.toStrings();
        DefaultTableModel tableModel = (DefaultTableModel) tableStruQue .getModel();
        tableModel.setRowCount(instrs.length);
        for(int i=0;i<instrs.length;i++){
            for(int j=0;j<instrs[i].length;j++){
                tableStruQue.setValueAt(instrs[i][j], i, j);
            }
        }
        
        
        //更新runningStateTable，要改
        String runningState[][] = kernel.manager.getRunningState();
        DefaultTableModel tableMode2 = (DefaultTableModel) runningStateTable .getModel();
        tableMode2.setRowCount(runningState.length);
        for(int i=0;i<runningState.length;i++){
            for(int j=0;j<runningState[i].length;j++){
                runningStateTable.setValueAt(runningState[i][j], i, j);
            }
        }
        
        

        
        //更新loadQueueTable，要改
             
         String loadQue[][] = kernel.memory.loadQueue();
        for(int i=0;i<loadQue.length;i++){
            for(int j=0;j<loadQue[i].length;j++){
                loadQueueTable.setValueAt(loadQue[i][j], i, j);
            }
        }
       
        //更新storeQueueTable，要改
         String stoQue[][] = kernel.memory.storeQueue();
        for(int i=0;i<stoQue.length;i++){
            for(int j=0;j<stoQue[i].length;j++){
                storeQueueTable.setValueAt(stoQue[i][j], i, j);
            }
        }
       
        //更新memoryTable，要改
          getMem();
          
          
          
        //更新reservationStationTable，要改
          String resMul[][] = kernel.mul.toStrings();
          String resAdd[][] = kernel.add.toStrings();
           for(int i=0;i<resMul.length;i++){
            for(int j=0;j<resMul[i].length;j++){
                reservationStationTable.setValueAt(resMul[i][j], i, j);
            }
        }
            for(int i=0;i<resAdd.length;i++){
            for(int j=0;j<resAdd[i].length;j++){
                reservationStationTable.setValueAt(resAdd[i][j], i+resMul.length, j);
            }
        }
      
          
          
        //更新registerTable，要改
       String reg[][] = kernel.register.toStrings();
        for(int i=0;i<reg.length;i++){
            for(int j=0;j<reg[i].length;j++){
                registerTable.setValueAt(reg[i][j], i, j);
            }
        }
         
        //更新time值
       timeTextField.setText(Integer.toString(kernel.cycle));
        }
    }